<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php
include './_timeout-logout.php';
include './connectMySQL.php';
include './building.php';
$db = new MySQLDatabase(); // create a Database object
$mysqli = $db->connect("infs3202-146", "spice*Dizzy6streak", "infs3202-146");
$hotelQuery = "select * from building where building_type ='hotel' limit 2";
$hostelQuery = "select * from building where building_type ='hostel' limit 2";
$hotelResult =  $mysqli->query($hotelQuery);
$hostelResult = $mysqli->query($hostelQuery);
if ($hotelResult || $hostelResult) {
    $buildingArray = [];
    while ($row = $hotelResult->fetch_assoc()) {
        $building = new Building($row);
        $buildingArray[] = $building;
    }
    while ($row = $hostelResult->fetch_assoc()) {
        $building = new Building($row);
        $buildingArray[] = $building;
    }
} else {
    die(mysql_error()); // useful for debugging
}
$db->disconnect();
?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>My places</title>
        <link href="css/lightbox.css" rel="stylesheet" >
        <link href="css/prac1.css" rel="stylesheet" >
    </head>
    <body>
        <a href="search.php">Search</a>
        
        <?php
        include './_login-container.php';
        ?>

        <?php
        $buildingType = "hotel";
        include './_preview-table.php';
        ?>

        <?php
        $buildingType = "hostel";
        include './_preview-table.php';
        ?>

        <?php
        for ($i = 1; $i < 4; $i++) {
            $titleNum = $i + 1;
            echo "<a href=\"images/hostel$i.jpg\" rel=\"lightbox[hostel]\" title=\"Hostel $titleNum\" style=\"display: none\"></a>";
            echo "<a href=\"images/hotel$i.jpg\" rel=\"lightbox[hotel]\" title=\"Hotel $titleNum\" style=\"display: none\"></a>";
        }
        ?>

        <?php
        if (isset($_SESSION["login_time"])) {
            include './_timeout-counter.php';
        }
        ?>

        <script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
        <script src="js/lightbox.js" type="text/javascript"></script>
    </body>
</html>